<template>
	<view>
		<view class="v-row">
			<view class="title">维修订单：</view>
			<view class="context">{{select=='3'?item.id:item.repairOrderCode}}</view>
			<view class="title" v-if="item.departmentName">{{item.departmentName}}</view>
			<view class="delete" v-if="select=='1'" @click.stop="close(item)">×</view>
		</view>
		<view class="v-row" v-if="isRepair &&item.rfid">
			<view class="title">电子标签：</view>
			<view class="context">{{item.rfid}}</view>
		</view>
		<view class="v-row" v-else-if="isRepair &&item.deviceCode && item.deviceCode!='a'">
			<view class="title">设备编码：</view>
			<view class="context">{{item.deviceCode}}</view>
		</view>
		<view class="v-row">
			<view class="title">设备名称：</view>
			<view class="context">{{item.deviceName}}</view>
			<view class="title">设备故障：</view>
			<view class="context">{{item.badName}}</view>
		</view>
		<view class="v-row" v-if="item.badDesc">
			<view class="title">故障描述：</view>
			<view class="context">{{item.badDesc}}</view>
		</view>
		<view class="v-row" v-if="item.badReason">
			<view class="title">异常原因：</view>
			<view class="context">{{item.badReason}}</view>
		</view>
		<view v-if="!isAcceptance">
			<view class="v-row" v-if="!isRepair">
				<view class="title " style="color: #1E6AD3;">紧急程度：</view>
				<view class="context" :style="{'color':item.troubleLevelValue==2?'red':'#1E6AD3'}">{{item.troubleLevelStr?item.troubleLevelStr:item.troubleLevel}}</view>
			</view>
			<view class="v-row" v-if="isRepair">
				<view class="title">紧急程度：</view>
				<view class="context">{{item.troubleLevelStr?item.troubleLevelStr:item.troubleLevel}}</view>
				<view class="title">提报类型：</view>
				<view class="context" v-if="isNumber">{{item.repairOrderType?setEnumsName(enums.enums.EnumRepairOrderType,item.repairOrderType):""}}</view>
				<view class="context" v-else>{{item.repairOrderType}}</view>
			</view>
			<view v-if="select=='4'" class="v-row">
				<view class="title">未通过原因：</view>
				<view class="context">{{item.returnReason}}</view>
			</view>
			<view v-if="select=='7'" class="v-row">
				<view class="title">延期原因：</view>
				<view class="context">{{item.deplayReason}}</view>
			</view>
			<view v-if="select=='7'" class="v-row">
				<view class="title">延期时间：</view>
				<view class="context">{{item.deplayDate}}</view>
			</view>
			<view class="v-row" v-if="item.repairOrderTypeValue!='0'">
				<view class="title" v-if="select!='3'&&item.repairOrderTypeValue!='0'">报修人：</view>
				<view class="context" v-if="select!='3'&&item.repairOrderTypeValue!='0'">{{select=='s'?item.addUserName:item.troubleUserName}}</view>
				<view class="title" v-if="repairUser">维修人：</view>
				<view class="context" v-if="repairUser">{{item.repairUserName}}</view>
			</view>
			<view class="v-row" v-if="item.repairOrderTypeValue!='0'">
				<view class="title" v-if="item.repairOrderTypeValue!='0'">停机状态：</view>
				<view class="context" v-if="item.repairOrderTypeValue!='0'">{{item.isShutdownStr?item.isShutdownStr:item.isShutDownStr?item.isShutDownStr:""}}</view>
				<view class="v-status" v-if="isRepair&&(select=='3'||select=='s')">{{stateDesc}}</view>
				<view class="delete" v-if="!isRepair&&(select=='3'||select=='s')" style="font-size: 16px;">{{item.repairOrderType}}</view>
			</view>
			<view class="v-row" v-show="item.troubleDate">
				<view class="title">报修时间：</view>
				<view class="context">{{item.troubleDate}}</view>
			</view>
			
			<view class="v-row" v-if="select!='3'&&select!='s'">
				<view class="title">设备位置：</view>
				<view class="context">{{item.location}}</view>
				<view class="border-bottom2" v-if="(select=='1'||select =='7')&& (isNumber?item.repairOrderType!=0:item.repairOrderTypeValue!=0)" @click.stop="transfer(item)">转派</view>
				<view class="v-status" v-if="isRepair">{{stateDesc}}</view>
				<view class="delete" v-if="!isRepair" style="font-size: 16px;">{{item.repairOrderType}}</view>
			</view>
		</view>
		<view v-if="isAcceptance">
			<view class="v-row">
				<view class="title">维修人：</view>
				<view class="context">{{item.repairUserName}}</view>
			</view>
			<view class="v-row">
				<view class="title">维修措施：</view>
				<view class="context">{{item.repairDesc}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import enums from '@/common/utils/enum.js'
	export default {
		data() {
			return {
				enums:enums,
			}
		},
		props: {
			item:{
				type:Object,
				default:{}
		   },
		   stateDesc:{
			   type:String,
			   default:""
		   },
		   isRepair:{
			   type:Boolean,
			   default:true
		   },
		   isAcceptance:{
		   		type:Boolean,
		   		default:false
		   },
		   isNumber:{
		   		type:Boolean,
		   		default:false
		   },
			 select:{
				 type:String,
				 default:""
			 },
			repairUser:{
				type:Boolean,
				default:true
			}
		},
		methods:{
			
			defer(item){
				console.log('点击了关闭');
				var that=this;
				uni.navigateTo({
					url: '/pages_repair/equipment-repairs/repair-orders/detail/repair-defer',
					success: function(res) {
					    // 通过eventChannel向被打开页面传送数据
					    res.eventChannel.emit('getItem', { data: item})
					}
				})
			},
			setEnumsName(list,value){
				var name="";
				if(value<list.length){
					name = list[value].text;
				}else{
					name=value;
				}
				return name;
			},
			close(item){
				var that = this
				uni.showActionSheet({
					itemList: ['延期处理'],
					success: function(res) {
						switch (res.tapIndex) {
							case 0:
								console.log("跳转至NFC识别页面")
								that.defer(item)
								break;
						}
					}
				})
			},
			transfer(item){
				console.log(item,"=====");
				uni.navigateTo({
					url: '/pages_repair/equipment-repairs/repair-orders/transfer/transfer?id='+item.id+"&tid="+item.deviceTroubleId,
				})
			}
		}
	}
	
</script>

<style>
	@import url("@/pages/general/general.css");
</style>